<template>
  <div>
    <el-button @click="getPosts">获取文章列表</el-button>
    <el-button @click="gotoMainpage">列表页面</el-button>
    <el-button @click="gotoDetialpage">详情页面</el-button>
    <el-button @click="gotoAddpage">新增页面</el-button>
    <ul>
      <li v-for="(post, index) in posts" :key="index">
        {{ post.title }}
      </li>
    </ul>
  </div>
</template>

<script>
import service from '@/utils/http';

export default {
  data() {
    return {
      posts: []
    }
  },
  methods: {
    gotoMainpage() {
      this.$router.push({path: 'mainpage'});
    },
    gotoDetialpage() {
      this.$router.push({path: 'detialpage'});
    },
    gotoAddpage() {
      this.$router.push({path: 'addnewPage'});
    },
    getPosts() {
      service.post('post/selectOne', {id: '1'}).then(res => {
        console.log(res)
      })
    }
  }
}
</script>
